package 剑指Offer.medium;

public class 数值的整数次方 {
    class Solution {
        public double myPow(double x, int n) {
            return recursion(x, n);
        }

        public double recursion(double x, int n) {
            if (n == 1) {
                return x;
            }
            double temp =  recursion(x, n / 2);
            if (n % 2 == 0) {
                return temp * temp;
            } else {
                return temp * x;
            }
        }
    }
}
